import org.apache.spark.{SparkConf, SparkContext}

object LineCountScala {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
      .setAppName("LineCount")
      .setMaster("local")

    val sc = new SparkContext(conf)
    sc.setLogLevel("INFO")
    val lines =  sc.textFile("src/main/resources/spark.txt")
    val pairs = lines.map(line=>(line,1))
    val pairsRDD = pairs.reduceByKey(_+_)
    pairsRDD.foreach(cont=>println(cont._1+" 出现 "+cont._2 +" 次"))

  }
}
